home *** CD-ROM | disk | FTP | other *** search
Text File | 1986-08-03 | 2.4 KB | 118 lines | [TEXT/MACA] |
- ( Keyboard reconfigurator, c 1986 J. Langowski / MacTutor )
- ( For reconfiguration of individual keys without using the Localizer )
-
- only forth also assembler also mac
-
- hex
- 494e4954 constant "init
- 21e constant keyb.type ( B: Mac+ )
- variable hand0 variable hand1
-
- : get.handles
- "init 0 call getresource hand0 !
- "init 1 call getresource hand1 !
- ;
-
- : get.key1.data ( | handle start.of.data )
- hand0 @ dup @ 7fffff and 14 +
- keyb.type c@ B <> if C + then dup w@ +
- ;
-
- : get.key2.data ( | handle start.of.data )
- hand1 @ dup @ 7fffff and 6 + dup w@ +
- keyb.type c@ B <> if 40 + then
- ;
-
- : keyin
- begin 2d emit 8 emit ?terminal ?dup until
- ;
-
- : keycode ( extracts keycode out of keyinfo )
- 100 / ff and ;
-
- : modifiers ( extracts modifiers from keyinfo )
- 1000000 / ff and ;
-
- : keyaddress { | mods keyc -- handle offset }
- dup modifiers -> mods keycode -> keyc
- keyc 41 < if get.key1.data
- dup mods E and + w@ + keyc +
- else get.key2.data
- mods 2 and
- if ( shift key down) 20 + then
- keyc 1f and +
- then
- ;
-
- : keytest
- begin keyin keyaddress c@ emit key drop drop again
- ;
-
-
- : get&show ( | handle offset )
- keyin dup key emit ." - Keycode = "
- dup modifiers swap keycode .
- ." , Modifiers = " binary
- <# # # # # #> type decimal
- keyaddress dup c@
- ." , actual mapping - " emit cr
- ;
-
- : keynum cr
- begin get&show drop drop again
- ;
-
- decimal
-
- : hello
- cls
- ." Macintosh Keyboard Remapper" cr
- ." © 1986 J.Langowski / MacTutor" cr cr
- ." Closing the window will update the resource file." cr cr
- ;
-
- : yesno begin key dup emit
- case
- 89 of 1 1 endof 121 of 1 1 endof
- 78 of 0 1 endof 110 of 0 1 endof
- cr ." y or n - " 0 swap
- endcase
- until
- ;
-
- : on.goaway 0 call updateresfile bye ;
-
- : remap
- hello
- get.handles
- begin
- ." Type the key you'd like to change - " cr
- get&show ( | handle offset )
- ." Do you want to remap this key (y/n) - " yesno cr
- if
- ." Enter the character to map this key to - "
- key dup emit cr
- swap c! ( store in mapping table of INIT resource)
- call changedresource
- else 2drop
- then cr
- again
- ;
-
- 164 user goaway-hook
-
- NEW.WINDOW remapper
- " Keyboard Configuration Editor" remapper TITLE
- 50 20 316 496 remapper BOUNDS
- ROUNDED VISIBLE CLOSEBOX NOGROWBOX remapper ITEMS
- 600 5000 terminal mapper
-
- : go.map activate remap ;
-
- : start
- remapper add
- remapper mapper build
- ['] on.goaway goaway-hook task-> mapper !
- remapper dup call selectwindow call setport
- mapper go.map
- ;